<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item :label="$t('名称')">
              <a-input :placeholder="$t('请输入名称')" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{ $t('查询') }}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{
                $t('重置')
              }}</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" v-has="'BisAppletSysAnnouncementController:add'">{{ $t('新增') }}</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            {{ $t('下载') }}
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" v-has="'BisAppletSysAnnouncementController:edit'">{{ $t('编辑') }}</a>
          <a-divider type="vertical" v-has="'BisAppletSysAnnouncementController:edit'" />
          <a-popconfirm :title="$t('确定删除吗?')" @confirm="() => handleDelete(record.id)">
            <a v-has="'BisAppletSysAnnouncementController:delete'">{{ $t('删除') }}</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <bis-applet-sys-modal ref="modalForm" @ok="modalFormOk"></bis-applet-sys-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import BisAppletSysModal from './modules/BisAppletSysModal'

export default {
  name: 'BisAppletSysAnnouncement',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    BisAppletSysModal,
  },
  data() {
    return {
      description: '系统公告管理页面',
      // 表头
      columns: [
        {
          title: this.$t('排序'),
          align: 'center',
          sorter: true,
          dataIndex: 'sort',
        },
        {
          title: this.$t('名称'),
          align: 'center',
          dataIndex: 'title',
        },
        {
          title: this.$t('状态'),
          align: 'center',
          dataIndex: 'status_dictText',
        },
        {
          title: this.$t('投放时间'),
          align: 'center',
          dataIndex: 'beginTime',
          customRender: function (t, r) {
            return r.beginTime + '~' + r.endTime
          },
        },
        {
          title: this.$t('公告内容'),
          align: 'center',
          dataIndex: 'content',
        },
        {
          title: this.$t('操作'),
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/applet/bisAppletSysAnnouncement/list',
        delete: '/applet/bisAppletSysAnnouncement/delete',
        deleteBatch: '/applet/bisAppletSysAnnouncement/deleteBatch',
        exportXlsUrl: '/applet/bisAppletSysAnnouncement/exportXls',
        importExcelUrl: 'applet/bisAppletSysAnnouncement/importExcel',
      },
      dictOptions: {},
    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>